package com.threegroup.web.controller;


import com.threegroup.common.dto.DishDTO;
import com.threegroup.common.utils.Result;
import com.threegroup.web.pojo.DishES;
import com.threegroup.web.service.DishForGuestService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.List;

@RequestMapping("/mp/dish")
@RestController
public class DishForGuestController {

    @Resource
    private DishForGuestService dishForGuestService;



    /**
     * 使用ELK实现的
     * 面对顾客的多条件连表查询
     * @param keywords
     * @return
     */
    @GetMapping("searchList")
    public Result<List<DishES>> queryDishForGuest(String keywords) throws IOException {
        Result<List<DishES>>  listResult =  dishForGuestService.queryDishForGuest(keywords);
        return listResult;
    }

    @GetMapping("list")
    public Result<List<DishES>> queryDishForGuestByCaIdAndStatus( String categoryId,String status ) throws IOException {
        Result<List<DishES>>  listResult =  dishForGuestService.queryDishForGuestByCaIdAndStatus(categoryId,status);
        return listResult;
    }



    /**
     * 用redis查Id
     * @param id
     * @return
     */
    @GetMapping("{id}")
    public Result<DishES> queryDishById(@PathVariable String id, HttpServletRequest request) {
        Result<DishES> result = dishForGuestService.queryDishById(id);
        return result;
    }
}
